--Tao TABLE DEAN
IF EXISTS (Select * from dbo.Sysobjects where name ='DEAN')
BEGIN
DROP TABLE DEAN
END
GO
CREATE TABLE DEAN
(
	TENDA		NVARCHAR (30),
	MADA		INT,
	DDIEM_DA	NVARCHAR (30),
	PHONG		INT	
	PRIMARY KEY (MADA)
)
-- Tao TABLE DIADIEM_PHG
IF EXISTS (Select * from dbo.Sysobjects where name ='DIADIEM_PHG')
BEGIN
DROP TABLE DIADIEM_PHG
END
GO
CREATE TABLE DIADIEM_PHG
(
	MAPHG		INT,
	DIADIEM		NVARCHAR (30)
	PRIMARY KEY (MAPHG, DIADIEM)
)
-- Tao TABLE NHANVIEN
IF EXISTS (Select * from dbo.Sysobjects where name ='NHANVIEN')
BEGIN
DROP TABLE NHANVIEN
END
GO
CREATE TABLE NHANVIEN
(
	HONV		NVARCHAR(10),
	TENLOT		NVARCHAR(20),
	TENNV		NVARCHAR(10),
	MANV		VARCHAR(10),
	NGSINH		DATETIME,
	DCHI		NVARCHAR(100),
	PHAI		NVARCHAR(5),
	LUONG		NUMERIC,
	MA_NQL		VARCHAR(10),
	PHG			INT
PRIMARY KEY (MANV)
)
--Tao TABLE PHONGBAN
IF EXISTS (Select * from dbo.Sysobjects where name ='PHONGBAN')
BEGIN
DROP TABLE PHONGBAN
END
GO
CREATE TABLE PHONGBAN
(
	TENPHG		NVARCHAR (30),
	MAPHG		INT,
	TRPHG		VARCHAR (10),
	NG_NHANCHUC	DATETIME,
PRIMARY KEY(MAPHG)
)
-- Tao TABLE THANNHAN
IF EXISTS (Select * from dbo.Sysobjects where name ='THANNHAN')
BEGIN
DROP TABLE THANNHAN
END
GO
CREATE TABLE THANNHAN
(
	MA_NVIEN		VARCHAR(10),
	TENTN			NVARCHAR(30),
	PHAI			VARCHAR(5),
	NGSINH			DATETIME,
	QUANHE			VARCHAR(15)
PRIMARY KEY (MA_NVIEN,TENTN)
)
-- Tao TABLE PHANCONG
IF EXISTS (Select * from dbo.Sysobjects where name ='PHANCONG')
BEGIN
DROP TABLE PHANCONG
END
GO
CREATE TABLE PHANCONG
(
	MA_NVIEN			VARCHAR(10),
	SODA				INT,
	THOIGIAN			NUMERIC
PRIMARY KEY (MA_NVIEN,SODA)
)
